Merge branch 'master' into routelist
authortsteven4 <tsteven4@gmail.com>
Wed, 27 Feb 2019 15:33:48 +0000 (08:33 -0700)
committertsteven4 <tsteven4@gmail.com>
Wed, 27 Feb 2019 15:33:48 +0000 (08:33 -0700)
including manual resolution of conflict in main.cc.

1  2 
defs.h
main.cc

diff --cc defs.h
Simple merge
diff --cc main.cc
index eb869e25223f5407a2ea5d7c06947980b71108e2,2ccf26e62f40b104ea46a2d9bd6dde63d2e00fdc..d19a6fd69d15c08406343b26135672cebbcbdf63
+++ b/main.cc
@@@ -211,21 -227,11 +227,13 @@@ run(const char* prog_name
    const char* ovec_opts = nullptr;
    const char* fvec_opts = nullptr;
    int opt_version = 0;
-   int did_something = 0;
-   const char* prog_name = argv[0]; /* argv is modified during processing */
+   bool did_something = false;
 -  queue* wpt_head_bak, *rte_head_bak, *trk_head_bak;  /* #ifdef UTF8_SUPPORT */
 -  signed int wpt_ct_bak, rte_ct_bak, trk_ct_bak;      /* #ifdef UTF8_SUPPORT */
 +  queue* wpt_head_bak;        /* #ifdef UTF8_SUPPORT */
 +  RouteList* rte_head_bak, *trk_head_bak; /* #ifdef UTF8_SUPPORT */
 +  signed int wpt_ct_bak;  /* #ifdef UTF8_SUPPORT */
 +  bool lists_backedup;  /* #ifdef UTF8_SUPPORT */
-   QStack<QargStackElement> qargs_stack = QStack<QargStackElement>();
+   QStack<QargStackElement> qargs_stack;
  
-   // Create a QCoreApplication object to handle application initialization.
-   // In addition to being useful for argument decoding, the creation of a
-   // QCoreApplication object gets Qt initialized, especially locale related
-   // QTextCodec stuff.
-   // For example, this will get the QTextCodec::codecForLocale set
-   // correctly.
-   QCoreApplication app(argc, argv);
    // Use QCoreApplication::arguments() to process the command line.
    QStringList qargs = QCoreApplication::arguments();
  
      fatal("Nothing to do!  Use '%s -h' for command-line options.\n", prog_name);
    }
  
+   return 0;
+ }
+ int
+ main(int argc, char* argv[])
+ {
+ #ifdef AFL_INPUT_FUZZING
+   AFL_INIT_ARGV();
+ #endif
+   int rc = 0;
+   const char* prog_name = argv[0]; /* may not match QCoreApplication::arguments().at(0)! */
+ // MIN_QT_VERSION in configure.ac should correspond to the QT_VERSION_CHECK arguments in main.cc and gui/main.cc
+ #if (QT_VERSION < QT_VERSION_CHECK(5, 9, 0))
+ #error This version of Qt is not supported.
+ #endif
+ #ifdef DEBUG_LOCALE
+   printf("Initial locale: %s\n",setlocale(LC_ALL, NULL));
+ #endif
+   // Create a QCoreApplication object to handle application initialization.
+   // In addition to being useful for argument decoding, the creation of a
+   // QCoreApplication object gets Qt initialized, especially locale related
+   // QTextCodec stuff.
+   // For example, this will get the QTextCodec::codecForLocale set
+   // correctly.
+   QCoreApplication app(argc, argv);
+   // The first invocation of QTextCodec::codecForLocale() or
+   // construction of QCoreApplication object
+   // may result in LC_ALL being set to the native environment
+   // as opposed to the initial default "C" locale.
+   // This was demonstrated with Qt5 on Mac OS X.
+ #ifdef DEBUG_LOCALE
+   printf("Locale after initial setup: %s\n",setlocale(LC_ALL, NULL));
+ #endif
+   // As recommended in QCoreApplication reset the locale to the default.
+   // Note the documentation says to set LC_NUMERIC, but QCoreApplicationPrivate::initLocale()
+   // actually sets LC_ALL.
+   // Perhaps we should restore LC_ALL instead of only LC_NUMERIC.
+   if (strcmp(setlocale(LC_NUMERIC,nullptr), "C") != 0) {
+ #ifdef DEBUG_LOCALE
+     printf("Resetting LC_NUMERIC\n");
+ #endif
+     setlocale(LC_NUMERIC,"C");
+ #ifdef DEBUG_LOCALE
+     printf("LC_ALL: %s\n",setlocale(LC_ALL, NULL));
+ #endif
+   }
+   /* reset LC_TIME for strftime */
+   if (strcmp(setlocale(LC_TIME,nullptr), "C") != 0) {
+ #ifdef DEBUG_LOCALE
+     printf("Resetting LC_TIME\n");
+ #endif
+     setlocale(LC_TIME,"C");
+ #ifdef DEBUG_LOCALE
+     printf("LC_ALL: %s\n",setlocale(LC_ALL, NULL));
+ #endif
+   }
+   (void) new gpsbabel::UsAsciiCodec(); /* make sure a US-ASCII codec is available */
+   global_opts.objective = wptdata;
+   global_opts.masked_objective = NOTHINGMASK; /* this makes the default mask behaviour slightly different */
+   global_opts.charset_name.clear();
+   global_opts.inifile = nullptr;
+   gpsbabel_now = time(nullptr);                       /* gpsbabel startup-time */
+   gpsbabel_time = current_time().toTime_t();                  /* same like gpsbabel_now, but freezed to zero during testo */
+   if (gpsbabel_time != 0) {   /* within testo ? */
+     global_opts.inifile = inifile_init(QString(), MYNAME);
+   }
+   init_vecs();
+   init_filter_vecs();
+   cet_register();
+   session_init();
+   waypt_init();
+   route_init();
+   rc = run(prog_name);
    cet_deregister();
    waypt_flush_all();
 -  route_flush_all();
 +  route_deinit();
    session_exit();
    exit_vecs();
    exit_filter_vecs();